/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.deployment.manager.visualizar;

import br.com.deployment.entidade.registroimovel.Operacao;
import br.com.deployment.manager.editar.ManagerEditarOperacao;
import br.com.deployment.servico.OperacaoServico;
import java.io.IOException;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
import javax.faces.context.FacesContext;

/**
 *
 * @author luciano
 */
@ManagedBean
@ViewScoped
public class ManagerVisaoOperacao implements Serializable{
    
    @EJB
    OperacaoServico operacaoServico;
    
    private Operacao operacao;
    
    private Operacao operacaoVisualizar;
    
    private List<Operacao> operacoes;

    
    public List<Operacao> todos(){
        return operacaoServico.operacoes();
    }
    
    public ManagerVisaoOperacao(){
        this.operacao = new Operacao();
        this.operacoes = new ArrayList<Operacao>();
    }
    
    public void buscar(){
        operacoes = operacaoServico.findOperacao(this.operacao);
    }
    
    public List<Operacao> getOperacoes() {
        return operacoes;
    }

    public void setOperacoes(List<Operacao> operacoes) {
        this.operacoes = operacoes;
    }
    
    public Operacao getOperacao() {
        return operacao;
    }

    public void setOperacao(Operacao operacao) {
        this.operacao = operacao;
    }
    
    
    public Operacao getOperacaoVisualizar() {
        return operacaoVisualizar;
    }

    public void setOperacaoVisualizar(Operacao operacaoVisualisar) {
        this.operacaoVisualizar = operacaoVisualisar;
    }
    
    public void redirect(String string, Operacao operacao) {
        try {
            FacesContext context = FacesContext.getCurrentInstance();
            this.operacaoVisualizar = operacao;
            context.getExternalContext().redirect(string);
        } catch (IOException ex) {
            Logger.getLogger(ManagerEditarOperacao.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
    
}
